<script setup>
import { reactive, ref } from 'vue'

// 父组件App.vue给子组件HelloWorld传递传值
// vue3通过defineProps来接收
defineProps({
  msg: String
})

// ref()一般用来定义基本数据类型,数字/字符串
// reactive()一般用来定义对象/数组/复杂的
const count = ref(0)
const count2 = ref('123')
const obj = reactive({
  name: '123',
  id: 123
})
const obj2 = reactive([1,2,3])

const obj3 = ref({
  name: '456',
  id: 123
})

const temp = count.value
const temp2 = obj3.value.name

</script>

<template>
  <!-- 父组件App.vue给子组件HelloWorld传递传值,将接收到的msg展示出来 -->
  <h1>{{ msg }}</h1>
  <p>{{count2}}</p>
  count2
  <p>{{obj}}</p>
  <p>obj</p>
  <p>{{obj3}}</p>

  <div class="card">
    <button type="button" @click="count++">count is {{ count }}</button>
    <p>
      Edit
      <code>components/HelloWorld.vue</code> to test HMR
    </p>
  </div>

  <p>
    Check out
    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
      >create-vue</a
    >, the official Vue + Vite starter
  </p>
  <p>
    Install
    <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
    in your IDE for a better DX
  </p>
  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}
</style>
